package com.huawei.hianalytics.ab.bc.bc;

import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import com.huawei.hianalytics.ab.bc.ef.ab;

public class cd {
    private static String ab(int i, String str) {
        String str2 = "";
        switch (i) {
            case 1:
            case 2:
            case 4:
            case 7:
            case 11:
                return "2G";
            case 3:
            case 5:
            case 6:
            case 8:
            case 9:
            case 10:
            case 12:
            case 14:
            case 15:
                return "3G";
            case 13:
                return "4G";
            default:
                return (str.equalsIgnoreCase("TD-SCDMA") || str.equalsIgnoreCase("WCDMA") || str.equalsIgnoreCase("CDMA2000")) ? "3G" : str;
        }
    }

    public static String ab(Context context) {
        if (context == null || context.getPackageManager().checkPermission("android.permission.ACCESS_NETWORK_STATE", context.getPackageName()) != 0) {
            ab.cd("hmsSdk", "not have network state phone permission!");
            return "";
        }
        ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService("connectivity");
        String str = "";
        if (connectivityManager != null) {
            NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
            if (activeNetworkInfo != null && activeNetworkInfo.isConnected()) {
                if (activeNetworkInfo.getType() == 1) {
                    return "WIFI";
                }
                if (activeNetworkInfo.getType() == 0) {
                    str = activeNetworkInfo.getSubtypeName();
                    ab.bc("hmsSdk", "Network getSubtypeName : " + str);
                    return ab(activeNetworkInfo.getSubtype(), str);
                } else if (activeNetworkInfo.getType() == 16) {
                    String str2 = "COMPANION_PROXY";
                    ab.cd("hmsSdk", "type name = " + str2);
                    return str2;
                }
            }
        }
        return str;
    }
}
